package com.qf.service.impl;

import com.qf.dao.CarsDao;
import com.qf.dao.OrderDao;
import com.qf.pojo.Citys;
import com.qf.pojo.Orders;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class OrderServiceImpl implements OrderService {
   @Autowired
    private  OrderDao orderDao;
    @Autowired
    private CarsDao carsDao;
    @Override
    public Citys selCity(int id) {
        return orderDao.selCity(id);
    }

    @Override
    public Orders viewOrder(Integer oId) {
        Orders order =orderDao.selectById(oId);
        if(order!=null){
            //取车地址
            Citys getCity = orderDao.selCity(order.getGetid());
            order.setGetCity(getCity);
            //还车地址
            Citys backCity = orderDao.selCity(order.getBackid());
            order.setBackCity(backCity);
            //车辆信息
            order.setCars(carsDao.selectOne(order.getCid()));
        }
        return order;
    }

    @Override
    public int addOne(Orders orders) {
        return orderDao.addOneOrder(orders);
    }


}
